package com.yunshang.shoppingmall.controller;

import com.yunshang.shoppingmall.ShopTask.Task.Hsys.HsysOrder;
import com.yunshang.shoppingmall.entity.ShopTaskState;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Timer;
import java.util.TimerTask;

@Controller
public class ShopState {

    @ResponseBody
    @RequestMapping(value="/SetStateT")
    public void SetStateT() {
        ShopTaskState.setStart(true);
        ShopTaskState.setUpdate(true);
    }

    @ResponseBody
    @RequestMapping(value="/SetStateF")
    public void SetStateF() {
        ShopTaskState.setStart(false);
    }

    @ResponseBody
    @RequestMapping(value="/TimerTask")
    public void TimerTask() {
        js=0;
        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            public void run() {
                Task1();
            }
        }, 1000);
    }

    private int js=0;

    public void Task1() {
        if (js < 10) {
            js++;
            System.out.println("abc" + js);
            Timer timer = new Timer();
            timer.schedule(new TimerTask() {
                public void run() {
                    Task1();
                }
            }, 1000);
        }
    }

    @ResponseBody
    @RequestMapping(value="/getHsysOrder")
    public void getHsysOrder() {

        HsysOrder hsysOrder = new HsysOrder();
        hsysOrder.getOrder();

    }

}
